package cn.ctodb.mall.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * A Goods.
 */
@Entity
@Table(name = "goods")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "goods")
public class Goods implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "goods_code")
    private String goodsCode;

    @Column(name = "name")
    private String name;

    @Column(name = "name_style")
    private String nameStyle;

    @Column(name = "click_count")
    private Integer clickCount;

    @Column(name = "provider_name")
    private String providerName;

    @Column(name = "stock")
    private Integer stock;

    @Column(name = "weight")
    private Integer weight;

    @Column(name = "market_price", precision=10, scale=2)
    private BigDecimal marketPrice;

    @ManyToOne
    private Brand brand;

    @ManyToOne
    private Shop shop;

    @ManyToOne
    private Category category;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getGoodsCode() {
        return goodsCode;
    }

    public Goods goodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
        return this;
    }

    public void setGoodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
    }

    public String getName() {
        return name;
    }

    public Goods name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNameStyle() {
        return nameStyle;
    }

    public Goods nameStyle(String nameStyle) {
        this.nameStyle = nameStyle;
        return this;
    }

    public void setNameStyle(String nameStyle) {
        this.nameStyle = nameStyle;
    }

    public Integer getClickCount() {
        return clickCount;
    }

    public Goods clickCount(Integer clickCount) {
        this.clickCount = clickCount;
        return this;
    }

    public void setClickCount(Integer clickCount) {
        this.clickCount = clickCount;
    }

    public String getProviderName() {
        return providerName;
    }

    public Goods providerName(String providerName) {
        this.providerName = providerName;
        return this;
    }

    public void setProviderName(String providerName) {
        this.providerName = providerName;
    }

    public Integer getStock() {
        return stock;
    }

    public Goods stock(Integer stock) {
        this.stock = stock;
        return this;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public Integer getWeight() {
        return weight;
    }

    public Goods weight(Integer weight) {
        this.weight = weight;
        return this;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public BigDecimal getMarketPrice() {
        return marketPrice;
    }

    public Goods marketPrice(BigDecimal marketPrice) {
        this.marketPrice = marketPrice;
        return this;
    }

    public void setMarketPrice(BigDecimal marketPrice) {
        this.marketPrice = marketPrice;
    }

    public Brand getBrand() {
        return brand;
    }

    public Goods brand(Brand brand) {
        this.brand = brand;
        return this;
    }

    public void setBrand(Brand brand) {
        this.brand = brand;
    }

    public Shop getShop() {
        return shop;
    }

    public Goods shop(Shop shop) {
        this.shop = shop;
        return this;
    }

    public void setShop(Shop shop) {
        this.shop = shop;
    }

    public Category getCategory() {
        return category;
    }

    public Goods category(Category category) {
        this.category = category;
        return this;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Goods goods = (Goods) o;
        if (goods.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, goods.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Goods{" +
            "id=" + id +
            ", goodsCode='" + goodsCode + "'" +
            ", name='" + name + "'" +
            ", nameStyle='" + nameStyle + "'" +
            ", clickCount='" + clickCount + "'" +
            ", providerName='" + providerName + "'" +
            ", stock='" + stock + "'" +
            ", weight='" + weight + "'" +
            ", marketPrice='" + marketPrice + "'" +
            '}';
    }
}
